package _01_动态数组;

public class _剑指_OfferII069山峰数组的顶部 {

    public static void main(String[] args) {


        _剑指_OfferII069山峰数组的顶部 v = new _剑指_OfferII069山峰数组的顶部();

        int[] ins = new int[]{24, 69, 100, 99, 79, 78, 67, 36, 26, 19};
        System.out.println(v.peakIndexInMountainArray(ins));
    }

    public int peakIndexInMountainArray(int[] arr) {
        int begin = 0;
        int end = arr.length - 1;
        while (begin < end) {
            int mid = begin + end >> 1;
            if (arr[mid] > arr[mid + 1]) {
                // 当前是降序组
                end = mid;
            } else {
                // 当前是升序组
                begin = mid + 1;
            }
        }
        return begin;
    }

}
